<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>v-on 实例</title>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <script type="text/javascript" src="../assets/js/vue.js"></script>
</head>
<body>
    <h1>v-on实例</h1>
    <hr>
    <div id="app">
        本场比赛得分：{{score}}<br/>
        <p>
            <button @click="plus()">加分</button>
            <button @click="jian()">减分</button>
            <input type="text" v-on:keyup.enter="onEnter" v-model="score2">
        </p>
   
    </div>
    <script type="text/javascript">
        var app=new Vue({
            el:'#app',
            data:{
                score:0,
                score2:1
            },
            methods:{
                plus:function(){
                    this.score++;
                },
                jian:function(){
                    this.score--;
                },
                onEnter:function(){
                    this.score=this.score+parseInt(this.score2);
                    // console.log(this.score)
                }
            },
           
        }); 
    </script>
</body>
</html>